<!--
  Generated template for the StrategyPage page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-header>
  <ion-toolbar color="gm-primary">
    <ion-segment [(ngModel)]="strategy" (ionChange)="onSegmentChanged($event)">
      <ion-segment-button value="strategy">
        分析
      </ion-segment-button>
      <ion-segment-button value="lessons">
        课程
      </ion-segment-button>
    </ion-segment>
  </ion-toolbar>
</ion-header>

<ion-content>
  <div *ngIf="user_info.type > 0">
    <ion-refresher (ionRefresh)="onRefresh($event)">
      <ion-refresher-content
          pullingIcon="arrow-dropdown"
          pullingText="下拉开始刷新"
          refreshingSpinner="circles"
          refreshingText="数据正在载入">
      </ion-refresher-content>
    </ion-refresher>

    <div [ngSwitch]="strategy">
      <div *ngSwitchCase="'strategy'">
        <ion-list *ngIf="strategy_count > 0">
          <ion-item-sliding *ngFor="let strategy of strategy_list" (click)="onItemSelected(0, strategy)">
            <ion-item>
              <div class="i-date">
                <ion-icon name="ios-calendar-outline"></ion-icon>
                &nbsp;{{strategy.created_at | dateformat}}
              </div>
              <div class="i-summary">{{strategy.content}}</div>
            </ion-item>
            <ion-item-options side="right" *ngIf="user_info.type > 2">
              <button ion-button color="danger" (click)="onItemDeleted(0, strategy)">
                <ion-icon name="gm-close"></ion-icon>
                关闭
              </button>
            </ion-item-options>
          </ion-item-sliding>
        </ion-list>

        <ion-infinite-scroll (ionInfinite)="onInfinite($event, 0)" *ngIf="strategy_list.length < strategy_count">
          <ion-infinite-scroll-content
              loadingSpinner="bubbles"
              loadingText="数据正在载入">
          </ion-infinite-scroll-content>
        </ion-infinite-scroll>

        <div *ngIf="strategy_count == 0" class="no-data stt-no-data">
          <img src="assets/icon/empty.png">
          <div>没有发布投资策略</div>
        </div>
      </div>

      <div *ngSwitchCase="'lessons'">
        <ion-list *ngIf="lesson_count > 0">
          <ion-item-sliding *ngFor="let lesson of lesson_list" (click)="onItemSelected(1, lesson)">
            <ion-item>
              <div class="i-date">
                <ion-icon name="ios-calendar-outline"></ion-icon>
                &nbsp;{{lesson.created_at | dateformat}}
              </div>
              <div class="i-summary">{{lesson.title}}</div>
            </ion-item>
            <ion-item-options side="right" *ngIf="user_info.type > 2">
              <button ion-button color="danger" (click)="onItemDeleted(1, lesson)">
                <ion-icon name="gm-close"></ion-icon>
                关闭
              </button>
            </ion-item-options>
          </ion-item-sliding>
        </ion-list>

        <ion-infinite-scroll (ionInfinite)="onInfinite($event, 1)" *ngIf="lesson_list.length < lesson_count">
          <ion-infinite-scroll-content
              loadingSpinner="bubbles"
              loadingText="数据正在载入">
          </ion-infinite-scroll-content>
        </ion-infinite-scroll>

        <div *ngIf="lesson_count == 0" class="no-data stt-no-data">
          <img src="assets/icon/empty.png">
          <div>没有发布投资学习视频</div>
        </div>
      </div>
    </div>
  </div>

  <div *ngIf="user_info.type == 0" class="ver-flex-center" padding>
    <h5>只有VIP会员才有权限浏览</h5>
    <button ion-button full (click)="onGetStrategy(1)">开通会员立即拥有全部权限</button>
    <!--<button ion-button full color="red" (click)="onGetStrategy(2)">500元购买一天的会员权限</button>-->
  </div>

  <div *ngIf="user_info.type < 0" class="ver-flex-center" padding>
    <h5>登录后查看您的浏览权限</h5>
    <button ion-button full (click)="onUserLogin()">用户登录</button>
  </div>
</ion-content>
